package com.action;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.util.DB;
import com.model.*;


public class afterclickingsell extends ActionSupport

{

	ResultSet res,res1,res2;
	String catname=null;
	ArrayList<String> category=new ArrayList<String>();
	ArrayList<String> subcategory=new ArrayList<String>();
	
	public ArrayList<String> getSubcategory() {
		return subcategory;
	}

	public void setSubcategory(ArrayList<String> subcategory) {
		this.subcategory = subcategory;
	}

	public ArrayList<String> getCategory() {
		return category;
	}

	public void setCategory(ArrayList<String> category) {
		this.category = category;
	}

	public String execute()throws Exception
	{
		
		String query="select * from category;";
		res=DB.readFromBmtcDB(query);
		
		while(res.next())
		{
			
		   catname=res.getString("catname");
		   category.add(catname);
		   
		}
		
		System.out.println("The categories are"+category);
		
		return "SUCCESS";
	}
	
	
	public String check()throws Exception
	{
		
		Map session;
		session=ActionContext.getContext().getSession();
		
		String ebayuserid=(String)session.get("ebayuserid");
		System.out.println("The ebayuserid is"+ebayuserid);
		
		
		if(ebayuserid==null)     // To check if the user has logged in or not
		{
			return "signin";
		}
	
		
		return "check";
		
		
	}
	
}